/**
 * Created by Rag_Panda on 2016/1/17.
 */
$app.controller("ArticleDetailController",function($scope,$http){
    $scope.haveLabel = [];
    $scope.canUseLabel = [];
    $scope.key = "";
    $scope.articleId= $("#label_articleid").val();
    $scope.getLabel = function(){
        $http.post("/api_sLabel",{query_limit:{
            search:$scope.key,
            opposite:$scope.articleId
        }}).success(function(response){
            $scope.canUseLabel = response.data;
        });

        $http.post("/api_sLabel",{query_limit:{
            article:$scope.articleId
        }}).success(function(response){
            $scope.haveLabel = response.data;
        });
    };

    $scope.addLabel =function(label_id){
        $http.post("/api_addArticleLabel",{
            article_id:$scope.articleId,
            label_id:label_id
        }).success(function(response){
            $scope.getLabel()
        });
    };
    $scope.delLabel =function(label_id){
        $http.post("/api_removeArticleLabel",{
            article_id:$scope.articleId,
            label_id:label_id
        }).success(function(response){
            $scope.getLabel()
        });
    };
    $scope.getLabel();
});